package behavior.observer.java;

import lombok.Data;

import java.util.Observable;

/**
 * 被观察者
 */
@Data
public class WarfareSubject extends Observable {

    public static Integer ADD = 1;
    public static Integer DELETE = 2;


    /**
     * 战争名称
     */
    private String name;


    public WarfareSubject(String name) {
        this.name = name;
    }

    public void add() {
        System.out.println("增加士兵");
        setChanged();
        notifyObservers(ADD);
    }

    public void remove() {
        System.out.println("减少士兵");
        setChanged();
        notifyObservers(DELETE);
    }
}
